<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>借贷管理系统</title>
    <meta name="keywords" content="借贷管理系统">
    <meta name="description" content="借贷管理系统">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="__PUBLIC__/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">

    <link href="__PUBLIC__/admin/css/plugins/summernote/summernote.css" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/plugins/summernote/summernote-bs3.css" rel="stylesheet">

    <link href="__PUBLIC__/admin/css/style.css?v=4.1.0" rel="stylesheet">


    <!--<link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/plugins/webuploader/webuploader.css">-->
    <!--<link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/demo/webuploader-demo.css">-->
    <script src="__PUBLIC__/admin/js/jquery.min.js?v=2.1.4"></script>
    <script src="__PUBLIC__/admin/js/bootstrap.min.js?v=3.3.6"></script>

    <script src="__PUBLIC__/admin/js/plugins/summernote/summernote.min.js"></script>
    <script src="__PUBLIC__/admin/js/plugins/summernote/summernote-zh-CN.js"></script>


    <!--<script src="__PUBLIC__/admin/js/plugins/webuploader/webuploader.min.js"></script>-->

    <!--<script src="__PUBLIC__/admin/js/demo/webuploader-demo.js"></script>-->
    <!--&lt;!&ndash;<script src="__PUBLIC__/admin/js/demo/webuploader_file.js"></script>&ndash;&gt;-->

</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">

    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>添加借贷</h5>
                </div>
                <div class="ibox-content" style="overflow: hidden">
                    <form role="form" class="form-horizontal" id="form1" action="__APP__/admin/index/addloan" method="post" enctype="multipart/form-data">

                        <div class="col-md-12">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">用户id：</label>
                                <div class="col-sm-2">
                                    <input type="text" id="register_id" name="register_id" class="form-control" placeholder="请输入用户id"  >

                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">推荐人姓名：</label>
                                <div class="col-sm-2">
                                    <input type="text" id="agent_name" name="agent_name" class="form-control" placeholder="请输入推荐人姓名"  >

                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">借款人姓名：</label>
                                <div class="col-sm-2">
                                    <input type="text" id="name" name="name" class="form-control" placeholder="请输入借款人姓名"  >

                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">贷款类型：</label>
                                <div class="col-sm-2">
                                    <input type="text" id="loan_name" name="loan_name" class="form-control" placeholder="请输入贷款类型"  >

                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">借款金额：</label>
                                <div class="col-sm-2">
                                    <input type="text" id="borrow_money" name="borrow_money" class="form-control" placeholder="请输入金额"  >

                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">手机号：</label>
                                <div class="col-sm-2">
                                    <input type="text" id="tel" name="tel" class="form-control" placeholder="请输入手机号"  >
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">城市：</label>
                                <div class="col-sm-2">
                                    <input type="text" id="city" name="city" class="form-control" placeholder="请输入城市"  >
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">身份证号码：</label>
                                <div class="col-sm-2">
                                    <input type="text" id="id_number" name="id_number" class="form-control" placeholder="请输入身份证号"  >
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">工资：</label>
                                <div class="col-sm-2">
                                    <input type="text" id="salary" name="salary" class="form-control" placeholder="请输入工资"  >
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">申请期限：</label>
                                <div class="col-sm-2">
                                    <input type="text" id="apply_limit" name="apply_limit" class="form-control" placeholder="请输入申请期限"  >
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">公积金：：</label>
                                <div class="col-sm-2">
                                    <input type="text" id="is_fund" name="is_fund" class="form-control" placeholder="请输入有或没有"  >
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">本地社保：</label>
                                <div class="col-sm-2">
                                    <input type="text" id="is_sec" name="is_sec" class="form-control" placeholder="请输入有或没有"  >
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">房产面积：</label>
                                <div class="col-sm-2">
                                    <input type="text" id="area" name="area" class="form-control" placeholder="请输入房产面积"  >
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">房产类型：</label>
                                <div class="col-sm-2">
                                    <input type="text" id="type" name="type" class="form-control" placeholder="请输入房产类型"  >
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">是否有车：</label>
                                <div class="col-sm-2">
                                    <input type="text" id="is_car" name="is_car" class="form-control" placeholder="请输入有或没有"  >
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">信用情况：</label>
                                <div class="col-sm-2">
                                    <input type="text" id="credit" name="credit" class="form-control" placeholder="请输入信用情况"  >
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">借款时间：</label>
                                <div class="col-sm-2">
                                    <input type="text"  name="dateandtime" class="form-control" placeholder="请输入借款时间"  >
                                </div>
                            </div>

                            <div class="col-sm-12 col-sm-offset-3">
                                <button class="btn btn-primary" type="button" id="" onclick=" return tijiao();">保存内容</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<style>
    .modal-backdrop {
        z-index: 1 !important;
    }
</style>



<script>
    //    $(document).ready(function() {
    //        $('#summernote').summernote();
    //    });
    //$('#summernote').code(); 获取编辑器内容
    $(document).ready(function() {
//      $("#uploader").powerWebUpload({ hiddenInputId: "uploadhidden" });
        $('#summernote').summernote({
            lang: 'zh-CN', // default: 'en-US'
            height: 500,
            onImageUpload: function(files, editor, welEditable) {
                sendFile(files[0],editor,welEditable);
            }
        });
    });

    function sendFile(file,editor,welEditable) {
        data = new FormData();
        data.append("file", file);
        $.ajax({
            data: data,
            type: "POST",
            url: "/index.php/admin/Tool/ajax_upload",
            cache: false,
            contentType: false,
            processData: false,
            dataType:'json',
            success: function(data) {
                editor.insertImage(welEditable, data.name);
            }
        });
    }

    function tijiao() {
        var register_id = document.getElementById("register_id").value;
        var agent_name = document.getElementById("agent_name").value;
        var name = document.getElementById("name").value;
        var loan_name = document.getElementById("loan_name").value;
        var borrow_money = document.getElementById("borrow_money").value;
        var tel = document.getElementById("tel").value;
        var city = document.getElementById("city").value;
        var id_number = document.getElementById("id_number").value;
        var salary = document.getElementById("salary").value;
        var apply_limit = document.getElementById("apply_limit").value;
        var is_fund = document.getElementById("is_fund").value;
        var is_sec = document.getElementById("is_sec").value;
        var area = document.getElementById("area").value;
        var type = document.getElementById("type").value;
        var is_car= document.getElementById("is_car").value;
        var credit = document.getElementById("credit").value;
        if(register_id=="")
        {
            alert("用户id不能为空！")
            document.getElementById("register_id").focus();
            return false;
        }else if(agent_name=="")
        {
            alert("推荐人姓名不能为空！")
            document.getElementById("agent_name").focus();
            return false;
        }
        else if(name=="")
        {
            alert("借款人姓名不能为空！")
            document.getElementById("name").focus();
            return false;
        }else if(!(/^[\u4e00-\u9fa5]{2,4}$/.test(name)))
        {
            alert("请输入借款人姓名！")
            document.getElementById("name").focus();
            return false;
        }else if(loan_name=="")
        {
            alert("贷款类型不能为空！");
            document.getElementById("loan_name").focus();
            return false;
        }else if(borrow_money.length<2)
        {
            alert("请输入10以上的数字！");
            document.getElementById("borrow_money").focus();
            return false;
        }else if(tel=="")
        {
            alert("手机号不能为空！");
            document.getElementById("tel").focus();
            return false;
        }else if(!(/^1[34578]\d{9}$/.test(tel))) {
            alert("请输入合法的手机号");
            document.getElementById("tel").focus();
            return false;
        }else if(city=="")
        {
            alert('所在城市不能为空！');
            document.getElementById("city").focus();
            return false;
        }else if (id_number == "")
        {
            alert("身份证号不能为空！");
            document.getElementById("id_number").focus();
            return false;
        } else if (id_number.length < 18 || id_number.length > 18)
        {
            alert("请输入18位身份证号！");
            document.getElementById("id_number").focus();
            return false;
        } else if (salary == "")
        {
            alert("工资不能为空！");
            document.getElementById("salary").focus();
            return false;
        } else if (isNaN(salary))
        {
            alert("请输入工资数！");
            document.getElementById("salary").focus();
            return false;
        }else if (apply_limit == "")
        {
            alert(" 申请期限不能为空！");
            document.getElementById("apply_limit").focus();
            return false;
        }else if (is_fund == "")
        {
            alert("公积金不能为空！");
            document.getElementById("is_fund").focus();
            return false;
        }else if (is_sec == "") {
            alert("本地社保不能为空！");
            document.getElementById("is_sec").focus();
            return false;
        }else if (area == "")
        {
            alert("房屋面积不能为空！");
            document.getElementById("area").focus();
            return false;
        } else if (isNaN(area))
        {
            alert("请输入房屋面积！");
            document.getElementById("area").focus();
            return false;
        }else if (type == "")
        {
            alert("房产类型不能为空！");
            document.getElementById("type").focus();
            return false;
        }else if (is_car == "")
        {
            alert("是否有车不能为空！");
            document.getElementById("is_car").focus();
            return false;
        }else if (credit == "")
        {
            alert("信用情况不能为空！");
            document.getElementById("credit").focus();
            return false;
        }


        $("#hidval").val($('#summernote').code() );
        // alert($("#uploadhidden").val());
        var ss= $("#hidval").val();
        $('#form1').submit();
    }
    $(function(){
        $("#id_number").blur(function() {
            var id_number = document.getElementById("id_number").value;
            $.ajax({
                type:"post",
                url:"/index.php/Admin/index/check",
                data:{'id_number':id_number},
                dataType:"json",
                success:function(msg){
                    if(msg==2){
                        alert("请输入合法的身份证！");
                        $("#submit").attr("disabled",true);
                    }
                }
            });
        });
    });
</script>
<link href="__PUBLIC__/js/jquery.uploadify-v2.1.4/uploadify.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="__PUBLIC__/js/jquery.uploadify-v2.1.4/swfobject.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/jquery.uploadify-v2.1.4/jquery.uploadify.v2.1.4.min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#uploadify").uploadify({
            'uploader': '__PUBLIC__/js/jquery.uploadify-v2.1.4/uploadify.swf', //uploadify.swf文件的路径
            'script': '/index.php/admin/Tool/ajax_upload', //处理文件上传的后台脚本的路径
            'cancelImg': '__PUBLIC__/js/jquery.uploadify-v2.1.4/cancel.png',
            //  'folder': 'UploadFile/<% = subpathName %>', //上传文件夹的路径
            'queueID': 'fileQueue', //页面中，你想要用来作为文件队列的元素的id
            'auto': true, //当文件被添加到队列时，自动上传
            'multi': true, //设置为true将允许多文件上传
            'fileExt': '*.jpg;*.gif;*.png', //允许上传的文件后缀
            'fileDesc': 'Web Image Files (.JPG, .GIF, .PNG)', //在浏览窗口底部的文件类型下拉菜单中显示的文本
            'sizeLimit': 1024*1000,  //上传文件的大小限制，单位为字节 100k
            'onCancel': function (event, ID, fileObj, data) { //当从上传队列每移除一个文件时触发一次
                //  alert('The upload of ' + fileObj.name + ' has been canceled!');
            },
            'onComplete': function (event, ID, fileObj, response, data) { //每完成一次文件上传时触发一次

                var result=eval('['+response+']');
                // $("#fileQueue").append('<img src="'+result[0].name+'" style="width：50px;height:50px;margin-right: 10px">');
                console.log(result)
                $("#comimg").attr( 'src',result[0].name)
                $('#uploadhidden').val(result[0].name);
            },
            'onAllComplete': function (event, data) { //当上传队列中的所有文件都完成上传时触发

            }
        });
    });
</script>

</body>

</html>



